<?php
/**
 * PHP Template.
 */
    session_start();

    include '../conexao.php';

    $query = "select * from `PACIENTE`";
    $query .= " order by `NOME` ASC ";

    echo 'sql: ' . $query;
    
    $rs = mysql_query($query);
    
    if (mysql_num_rows($rs) > 0)
    {
        /* mensagem */
        $message = '<html>';
        $message .= '<head>';
        $message .= '<title>Lista atualizada de Pacientes da Ligasis</title>';
        $message .= '</head>';
        $message .= '<body>';
        $message .= '<table>';
        
        while ($fields = mysql_fetch_array($rs))
        {
            $message .= ' <tr>';
            $message .= '  <th>' . $fields['NOME'] . '</th>';
            $message .= '  <th>' . $fields['CPF'] . '</th>';
            $message .= ' </tr>';
        }
        
        $message .= '</table>';
        $message .= '</body>';
        $message .= '</html>';
        
        echo $message;
    }
    else
    {
        //sem pacientes.
        echo '<br>Sem registros';
    }
?>
